package com.forbet.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * @author:hading
 * @create: 2024-07-24 17:47
 * @Description:
 */
@Configuration
public class TaskSchedulerConfig {

    @Bean
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        scheduler.setPoolSize(4); // 设置线程池的大小
        scheduler.setThreadNamePrefix("MyTaskScheduler-"); // 设置线程名称前缀
        scheduler.initialize(); // 初始化调度器
        return scheduler;
    }
}
